<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="modal-dialog ms-modal-dialog" style="width:600px; margin-top: 100px;">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
        class="sr-only">Close</span></button>
      <h4 class="modal-title">服务供方创建</h4>
    </div>

    <div class="form-horizontal ms-form modal-search-form" data-validate="true" style="margin-top:30px;">

      <div class="form-group ms-form-group">
        <label class="col-xs-3 control-label">服务供方代码或名称：</label>
        <div class="col-xs-8">
          <input type="text" class="form-control" name="code" data-validate="required" placeholder="公司代码或名称"
                 tabindex="3" autocomplete="off"/>
        </div>
      </div>

      <div class="form-group ms-form-group">
        <label class="col-xs-3 control-label">服务供方类型：</label>
        <div class="col-xs-8">
          <select class="select2 form-control" name="type" tabindex="4" data-validate="required">
            <option></option>
            <c:forEach var="type" items="${enums['SupplierType'] }">
              <option value="${type}">${type.description}</option>
            </c:forEach>
          </select>
        </div>
      </div>

      <div class="form-group ms-form-group">
        <label class="col-xs-5 control-label"></label>
        <div class="col-xs-7">
          <button type="button" id="code-search" class="btn ms-btn btn-primary">查询</button>
        </div>
      </div>

    </div>

    <hr>


    <form class="form-horizontal ms-form modal-search-form" role="form" method="POST" action="${ctx.host}/suppliers"
          data-validate="true">

      <input type="hidden" name="orgId" value="">
      <input type="hidden" name="code" value="">
      <input type="hidden" name="name" value="">
      <input type="hidden" name="shortName" value="">
      <input type="hidden" name="type" value="">

      <div class="modal-body">

        <div class="form-group ms-form-group " id="tip" style="text-align:center; color:red;">
          <p class="form-control-static"></p>
        </div>

        <div class="form-group ms-form-group create-panel">
          <label class="col-xs-3 control-label">服务供方代码：</label>
          <div class="col-xs-8">
            <p class="form-control-static" id="supplierCode"></p>
          </div>
        </div>

        <div class="form-group ms-form-group create-panel">
          <label class="col-xs-3 control-label">服务供方名称：</label>
          <div class="col-xs-8">
            <p class="form-control-static" id="supplierName"></p>
          </div>
        </div>

        <div class="form-group ms-form-group create-panel">
          <label class="col-xs-3 control-label">服务供方级别：</label>
          <div class="col-xs-8">
            <select class="select2 form-control" name="level" tabindex="1" id="level">
              <option value=""></option>
              <c:forEach var="level" items="${enums['SupplierLevel'] }">
                <option value="${level}">${level.description}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <div class="form-group ms-form-group" id="company">
          <label class="col-xs-3 control-label">挂靠管理公司：</label>
          <div class="col-xs-8">
            <select class="select2 form-control" name="parentId" data-validate="required" tabindex="1">
              <option value=""></option>
              <c:forEach var="supplier" items="${firstLevelSuppliers}">
                <option value="${supplier.id}">${supplier.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <div class="form-group ms-form-group create-panel">
          <label class="col-xs-3 control-label">默认分区：</label>
          <div class="col-xs-8">
            <select class="select2 form-control" name="branch" tabindex="2">
              <option value=""></option>
              <c:forEach var="branch" items="${selection.branch}">
                <option value="${branch.id}">${branch.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <div class="form-group ms-form-group create-panel">
          <label class="col-xs-3 control-label">是否VAM使用方：</label>
          <div class="col-xs-8">
            <select class="select2 form-control" name="vam" data-validate="required" tabindex="2">
              <option value="false">否</option>
              <option value="true">是</option>
            </select>
          </div>
        </div>

      </div>

      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary disabled">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary disabled" data-dismiss="modal">取消</button>
      </div>

    </form>
  </div>
</div>

<script type="text/javascript">
  $(document).ready(function () {

    $('select[name="type"]').select2({
      placeholder: '请选择类型',
      minimumResultsForSearch: -1,
      allowClear: true
    });

    $('select[name="level"]').select2({
      placeholder: '请选择供方级别',
      minimumResultsForSearch: -1,
      allowClear: true
    });

    $('select[name="parentId"]').select2({
      placeholder: '请选择挂靠管理公司',
      minimumResultsForSearch: 5,
      allowClear: true
    });

    $('select[name="branch"]').select2({
      placeholder: '请选择分区',
      minimumResultsForSearch: -1,
      allowClear: true
    });

    $('select[name="vam"]').select2({
      placeholder: '请选择分区',
      minimumResultsForSearch: -1,
      allowClear: true
    });

  })
</script>